home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_handlehistory.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  122 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <intuition/sghooks.h>    /* For struct SGWork */
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. /*****************************************************************************/
  23.  
  24. VOID
  25. LTP_HandleHistory(struct SGWork *Work)
  26. {
  27.     ObjectNode *Node;
  28.  
  29.     if(GETOBJECT(Work->Gadget,Node))
  30.     {
  31.         if(Node->Special.String.HistoryHook)
  32.         {
  33.             struct Node    *Choice;
  34.             struct MinList *List;
  35.  
  36.             Choice    = NULL;
  37.             List    = Node->Special.String.HistoryHook->h_Data;
  38.  
  39.             if(Work->IEvent->ie_Qualifier & QUALIFIER_SHIFT)
  40.             {
  41.                 if(Work->IEvent->ie_Code == CURSORUP)
  42.                 {
  43.                     if(List->mlh_Head->mln_Succ)
  44.                         Choice = (struct Node *)List->mlh_Head;
  45.                 }
  46.                 else
  47.                 {
  48.                     if(List->mlh_Head->mln_Succ)
  49.                         Choice = (struct Node *)List->mlh_TailPred;
  50.                 }
  51.             }
  52.             else
  53.             {
  54.                 struct Node *Current = Node->Special.String.CurrentNode;
  55.  
  56.                 if(Work->IEvent->ie_Code == CURSORUP)
  57.                 {
  58.                     if(Current)
  59.                     {
  60.                         if(Current->ln_Pred->ln_Pred)
  61.                             Choice = Current->ln_Pred;
  62.                         else
  63.                             Choice = Current;
  64.                     }
  65.                     else
  66.                     {
  67.                         if(List->mlh_Head->mln_Succ)
  68.                             Choice = (struct Node *)List->mlh_TailPred;
  69.                     }
  70.                 }
  71.                 else
  72.                 {
  73.                     if(Current)
  74.                     {
  75.                         if(Current->ln_Succ->ln_Succ)
  76.                             Choice = Current->ln_Succ;
  77.                     }
  78.                 }
  79.             }
  80.  
  81.             if(Choice != Node->Special.String.CurrentNode)
  82.             {
  83.                 LONG Len;
  84.  
  85.                 if(Choice)
  86.                 {
  87.                     Len = strlen(Choice->ln_Name);
  88.  
  89.                     if(Len >= Work->StringInfo->MaxChars)
  90.                         Len = max(0,Work->StringInfo->MaxChars - 1);
  91.  
  92.                     if(Len > 0)
  93.                         CopyMem(Choice->ln_Name,Work->WorkBuffer,Len);
  94.                 }
  95.                 else
  96.                     Len = 0;
  97.  
  98.                 Work->WorkBuffer[Len]    = 0;
  99.                 Work->NumChars            = Len;
  100.                 Work->BufferPos            = Len;
  101.  
  102.                 if(Node->Type == INTEGER_KIND)
  103.                 {
  104.                     #ifdef DO_HEXHOOK
  105.                     {
  106.                         LTP_ConvertNum((Node->Min < 0),Work->WorkBuffer,&Work->LongInt);
  107.                     }
  108.                     #else
  109.                     {
  110.                         Work->LongInt = LTP_Atol(Work->WorkBuffer);
  111.                     }
  112.                     #endif    /* DO_HEXHOOK */
  113.                 }
  114.  
  115.                 Node->Special.String.CurrentNode = Choice;
  116.  
  117.                 Work->Actions = (Work->Actions & ~SGA_BEEP) | SGA_USE | SGA_REDISPLAY;
  118.             }
  119.         }
  120.     }
  121. }
  122.